const app = getApp();
Component({
  properties: {
    current:{
      type:String,
      value:"0"
    }
  },
  data: {
    isIphoneX:false,
    play:1,
    currentSongbum:'',
    setInter:'',
  },
  ready:function () {
    let modelmes = wx.getStorageSync('modelmes');
    let isIphoneX = app.globalData.isIphoneX;
    
    var that = this;

    that.setData({
      isIphoneX: isIphoneX
    })
    that.playmusic()
  },
  methods: {
    handelBtn(e){
      let url = e.currentTarget.dataset.url;
      let currentUrl ='/'+ getCurrentPages()[getCurrentPages().length - 1].route
      if(currentUrl == url){
        return
      }
      else{ 
        wx.redirectTo({
          url,
        })
      }
    },
    playmusic(e){
      clearInterval(app.globalData.setInter2)
      var that=this;
      console.log(getCurrentPages()[0].route)
      if(getCurrentPages()[0].route!='pages/Playing/Playing'){
        app.globalData.setInter2 = setInterval(res => {
          if(app.globalData.songlist && app.globalData.songlist.length>0){
            that.setData({
              currentSongbum:app.globalData.songlist[(app.globalData.currentIndex || 0)].imgUrl
            })
            console.log(that.data.currentSongbum)
          }

          if(app.globalData.play){
            that.setData({
              play: app.globalData.play
            })
          }
          if(app.globalData.play==1){
            clearInterval(app.globalData.setInter2)
          }
        },1000)
      }else{
        clearInterval(app.globalData.setInter2)
      }
      
    },
  }
})
